home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir42 / c7105.zip / SCRNFLDS.TPX < prev    next >
Text File  |  1994-03-02  |  43KB  |  589 lines

  1. #!┌───────────────────────────┤Template Segment├───────────┬─────────────────┐
  2. #!│                              SrcnFlds.TPX              │Version: 3007.105│
  3. #!├───────────────────────────────┤Contents├───────────────┴─────────────────┤
  4. #!│Structure             Type       Description                              │
  5. #!│────────────────────  ─────────  ─────────────────────────────────────────│
  6. #!│ScreenSetupRoutines   GROUP      Pre-Edit (When field is selected) code   │
  7. #!│ScreenEditRoutines    GROUP      Post-Edit (When field is completed) code │
  8. #!│FieldEditCode         GROUP      Writes code associated with "When field  │
  9. #!│                                   Is Completed" fields                   │
  10. #!│PrimeRelationFields   GROUP      Primes relation key fields and return    │
  11. #!│                                   values before procedure call           │
  12. #!│FillRelationFields    GROUP      Refills relation key fields and return   │
  13. #!│                                   values after procedure call            │
  14. #!│ScreenEditLookupCode  GROUP      Generates code associated with Must-Be-  │
  15. #!│                                   In-File validations                    │
  16. #!│CallScreenFieldEdit   GROUP      Generates code associated with non-Must- │
  17. #!│                                   Be-In-File post-edit code              │
  18. #!│PrimeLookups          GROUP      Searches the dictionary for lookups or   │
  19. #!│                                   relations for a screen field           │
  20. #!│RangeCode             GROUP      Generates Range Validation Code          │
  21. #!│FieldLookupCode       GROUP      Generates Post-Edit Must-Be-In-File      │
  22. #!│                                   field validation                       │
  23. #!│SetGenerationFlags    GROUP      Sets flags to generate CASE SELECTED()   │
  24. #!│                                   and CASE FIELD() structures in main    │
  25. #!│                                   body accept loops                      │
  26. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  27. #!│Version   Comments                                                        │
  28. #!│────────  ────────────────────────────────────────────────────────────────│
  29. #!│3007.000  Release of CDD3 version 3007 templates                          │
  30. #!│3007.100  Repaired ScreenSetupRoutines                                    │
  31. #!│3007.105  Repaired ScreenEditRoutines                                     │
  32. #!└──────────────────────────────────────────────────────────────────────────┘
  33. #!
  34. #GROUP(%ScreenSetupRoutines)                     #!Write Screen Field Setup Code
  35. #!
  36. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  37. #!│                          %ScreenSetupRoutines          │Version: 3007.100│
  38. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  39. #!│Purpose:      Generate Pre-Edit (When Field is Selected) code for ENTRY   │
  40. #!│              fields.                                                     │
  41. #!│Called From:  Any procedure template that has a screen defined            │
  42. #!│Assumptions:  That a %Screen is defined.                                  │
  43. #!│Inserts:      %PrimeLookups                                               │
  44. #!│              %PrimeRelationFields                                        │
  45. #!│              %FillRelationFields                                         │
  46. #!│Symbols Set:  None                                                        │
  47. #!│Notes:        This group generates all of the "OF xxx" cases for the      │
  48. #!│              CASE SELECTED() structure of an accept loop.                │
  49. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  50. #!│Version   Comments                                                        │
  51. #!│────────  ────────────────────────────────────────────────────────────────│
  52. #!│3007.000  Release of CDD3 version 3007 templates                          │
  53. #!│3007.100  Repaired faulty assignment statement.  Line read:               │
  54. #!│          %ScreenFieldUse <> %ScreenFieldSetupReturnValue, should be:     │
  55. #!│          %ScreenFieldUse = %ScreenFieldSetupReturnValue.                 │
  56. #!└──────────────────────────────────────────────────────────────────────────┘
  57. #!
  58. #FOR(%ScreenField)                               #! FOR Each Screen Field
  59.   #IF(%ScreenFieldSetup)                         #! IF Setup Code Provided
  60. OF %ScreenField                                  #<! Setup %ScreenFieldUse field
  61.     #IF(%ScreenFieldSetupType='PROCEDURE')       #! If Setup is Proc Call
  62.       #SET(%LookupFromField,%Null)               #! Clear lookup field flag
  63.       #SET(%LookupFromFile,%Null)                #! Clear lookup file flag
  64.       #FIX(%Field,%ScreenFieldUse)               #! FIX to process FIELD
  65.       #FIX(%File,%FieldFile)                     #! FIX to process FIELD FILE
  66.       #IF(%NonStopSelect)                        #! IF proc has 'Save Mode'
  67.   IF ~NonStopSelect                              #<! IF Not in Save Mode
  68.       #ENDIF                                     #! END (If proc has save mode)
  69.       #SET(%LocateField,%ScreenFieldSetupReturnValue) #! Find Return Value, is any
  70.       #INSERT(%PrimeLookups)                     #! Look For Relations
  71.       #IF(%LookupFromFile)                       #! IF a Related File Found
  72.         #FIX(%Relation,%LookupFromFile)          #! FIX to process RELATION
  73.     #INSERT(%PrimeRelationFields)                #! Prime Key Fields
  74.       #ELSE                                      #! ELSE (No Related File)
  75.         #IF(%ScreenFieldSetupReturnValue)        #! If Return Value provided
  76.     %ScreenFieldSetupReturnValue = %ScreenFieldUse #<! Prime Return Value
  77.         #ENDIF                                   #! END (If Return Value...)
  78.       #ENDIF                                     #! END (If No Relation)
  79.     SETKEYCODE(ShftEnter)                        #<! Set KeyCode for Selection
  80.     %ScreenFieldSetup                            #<! Call the Setup Proc
  81.       #IF(%LookupFromFile)                       #! IF a Related File Found
  82.     #INSERT(%FillRelationFields)                 #! Fill the key fields
  83.       #ELSE                                      #! ELSE (No Related File)
  84.         #IF(%ScreenFieldSetupReturnValue)        #! If Return Value provided
  85.     IF KEYCODE() <> EscKey                       #<! IF User didn't ESCAPE
  86.       %ScreenFieldUse = %ScreenFieldSetupReturnValue #<! Fill Screen Field
  87.     END                                          #<! END (IF User didn't Escape)
  88.         #ENDIF                                   #! END (IF Return Value)
  89.       #ENDIF                                     #! END (If Related File...)
  90.     DISPLAY                                      #<! DISPLAY new values
  91.       #IF(%NonStopSelect)                        #! IF proc has 'Save Mode'
  92.   END                                            #<! END (If Not in 'Save Mode')
  93.       #ENDIF                                     #! END (IF Proc has save mode)
  94.     #ELSE                                        #! ELSE (Setup not Proc Call)
  95.   %ScreenFieldSetup                              #<! Write Setup Code
  96.     #ENDIF                                       #! END (If Setup Proc Call)
  97.   #ENDIF                                         #! END (If Setup Provided)
  98. #ENDFOR                                          #! END (For Each Screen Field)
  99. #!***************************************************************************
  100. #GROUP(%ScreenEditRoutines)                      #!Write Screen Field Edit Code
  101. #!
  102. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  103. #!│                          %ScreenEditRoutines           │Version: 3007.000│
  104. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  105. #!│Purpose:      Generate Post-Edit (When Field is Completed) code for ENTRY │
  106. #!│              fields.                                                     │
  107. #!│Called From:  Any procedure template that has a screen defined            │
  108. #!│Assumptions:  That a %Screen is defined, and that %ScreenField is fixed   │
  109. #!│              to a valid screen field.                                    │
  110. #!│Inserts:      %RangeCode                                                  │
  111. #!│              %FieldEditCode                                              │
  112. #!│              %FieldLookupCode                                            │
  113. #!│Symbols Set:  None                                                        │
  114. #!│Notes:        This group generates one "OF xxx" case for the CASE FIELD() │
  115. #!│              structure of an accept loop.                                │
  116. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  117. #!│Version   Comments                                                        │
  118. #!│────────  ────────────────────────────────────────────────────────────────│
  119. #!│3007.000  Release of CDD3 version 3007 templates                          │
  120. #!│3007.105  Re-Fixed field if the FIX to File failed.  This was causing     │
  121. #!│          problems in the Range Code for Non-File related fields not      │
  122. #!│          working.                                                        │
  123. #!└──────────────────────────────────────────────────────────────────────────┘
  124. #!
  125. #IF(%ScreenFieldType='ENTRY')                    #! IF an ENTRY field
  126.   #FIX(%Field,%ScreenFieldUse)                   #! FIX to process FIELD
  127.   #FIX(%File,%FieldFile)                         #! FIX to process FIELD FILE
  128.   #IF(NOT %File)                                 #! IF File NOT set
  129.     #FIX(%Field,%ScreenFieldUse)                 #! RE-FIX to process FIELD
  130.   #ENDIF                                         #! END (IF File NOT set)
  131.   #SET(%GenScreenFieldEdit,'TRUE')               #! Default to Gen Edit Code
  132.   #SET(%GenRangeCode,%Null)                      #! Default to NOT gen range code
  133.   #IF(%FieldRangeLow)                            #! IF a Low range on field
  134.     #SET(%GenRangeCode,'TRUE')                   #! Flag to gen range code
  135.   #ELSIF(%FieldRangeHigh)                        #! IF a High range on field
  136.     #SET(%GenRangeCode,'TRUE')                   #! Flag to gen range code
  137.   #ELSIF(%FieldLookup)                           #! if Must Be In File
  138.   #ELSIF(%ScreenFieldEdit)                       #! or Edit Code provided
  139.   #ELSE                                          #! otherwise
  140.     #SET(%GenScreenFieldEdit,%Null)              #! Flag to NOT gen code
  141.   #ENDIF                                         #! END (If FieldRangeLow...)
  142.   #IF(%GenScreenFieldEdit)                       #! IF we have to gen edit code
  143.     #SET(%LookupFromField,%Null)                 #! Clear lookup field flag
  144.     #SET(%LookupFromFile,%Null)                  #! Clear lookup file flag
  145. OF %ScreenField                                  #<! Completed %ScreenFieldUse field
  146.     #IF(%GenRangeCode)                           #! IF Range Code Needed
  147.   #INSERT(%RangeCode)                            #! Generate Range Code
  148.     #ENDIF                                       #! END (If range code needed)
  149.     #IF(%ScreenFieldEdit)                        #! IF Edit Code Provided
  150.   #INSERT(%FieldEditCode)                        #! Generate Edit Code
  151.     #ENDIF                                       #! END (If Edit Code...)
  152.     #IF(%FieldLookup)                            #! IF Must Be In File
  153.   #INSERT(%FieldLookupCode)                      #! Generate Validation Code
  154.     #ENDIF                                       #! END (If Must Be...)
  155.   #ENDIF                                         #! END (If gen Edit Code)
  156. #ELSE                                            #! ELSE (If not entry field)
  157.   #IF(%ScreenFieldEdit)                          #! If Edit Code Provided
  158. OF %ScreenField                                  #<! Completed %ScreenFieldUse field
  159.   %ScreenFieldEdit                               #<! Generate Edit Code
  160.   DISPLAY                                        #<! DISPLAY new value
  161.   #ENDIF                                         #! END (If Edit Code...)
  162. #ENDIF                                           #! END (If Entry Field)
  163. #!***************************************************************************
  164. #GROUP(%FieldEditCode)                           #!Proc/Source Code Generation
  165. #!
  166. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  167. #!│                             %FieldEditCode             │Version: 3007.000│
  168. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  169. #!│Purpose:      Writes code associated with "When Field Is Completed"       │
  170. #!│              Procedure Calls                                             │
  171. #!│Called From:  %ScreenEditRoutines #GROUP                                  │
  172. #!│Assumptions:  That a %Screen is defined, and that %ScreenField is fixed   │
  173. #!│              to a valid screen field.                                    │
  174. #!│Inserts:      %PrimeLookups                                               │
  175. #!│              %ScreenEditLookupCode                                       │
  176. #!│              %CallScreenFieldEdit                                        │
  177. #!│Symbols Set:  None                                                        │
  178. #!│Notes:        None                                                        │
  179. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  180. #!│Version   Comments                                                        │
  181. #!│────────  ────────────────────────────────────────────────────────────────│
  182. #!│3007.000  Release of CDD3 version 3007 templates                          │
  183. #!└──────────────────────────────────────────────────────────────────────────┘
  184. #!
  185. #IF(ScreenFieldEditType='PROCEDURE')             #! IF Edit Code is Proc Name
  186.   #SET(%LocateField,%ScreenFieldEditReturnValue) #! Prime Locate Field
  187.   #INSERT(%PrimeLookups)                         #! Look For Relations
  188.   #IF(%LookupFromFile)                           #! IF a Related File Found
  189.                                                  #<! Field Related to %LookupFromField
  190.     #FIX(%Relation,%LookupFromFile)              #! FIX to process RELATION
  191. #INSERT(%ScreenEditLookupCode)                   #! and Call the Lookup Code
  192.   #ELSE                                          #! ELSE (If no Relation)
  193.                                                  #<! No Relation Found
  194.     #IF(%ScreenFieldEditHotKey)                  #! If a Hot Key specified
  195.                                                  #<! %ScreenFieldEditHotKey calls PROC
  196. IF KEYCODE() = %ScreenFieldEditHotKey            #<! IF Hotkey completed field
  197.   #INSERT(%CallScreenFieldEdit)                  #! write non-lookup edit code
  198.   DISPLAY                                        #<! Display New Values
  199. END                                              #<! END (IF hotkey...)
  200.     #ELSE                                        #! ELSE (No Hotkey provided)
  201.       #IF(%NonStopSelect)                        #! IF In Proc with field validation
  202. IF ~NonStopSelect                                #<! IF NOT in non-stop select
  203.   #INSERT(%CallScreenFieldEdit)                  #! write non-lookup edit code
  204.   DISPLAY                                        #<! Display New Values
  205. END                                              #<! END (If NOT Non-Stop...)
  206.       #ELSE                                      #! ELSE (Not in Non-Stop Proc)
  207. #INSERT(%CallScreenFieldEdit)                    #! write non-lookup edit code
  208. DISPLAY                                          #<! Display New Values
  209.       #ENDIF                                     #! END (If Non-Stop Select)
  210.     #ENDIF                                       #! END (If Hot Key Defined)
  211.   #ENDIF                                         #! END (If Related File Found)
  212. #ELSE                                            #! ELSE (Not a Proc Call)
  213. %ScreenFieldEdit                                 #<! Write Source Code
  214. #ENDIF                                           #! END (If Edit Code...)
  215. #!***************************************************************************
  216. #GROUP(%PrimeRelationFields)                     #!Prime all Related Fields
  217. #!
  218. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  219. #!│                          %PrimeRelationFields          │Version: 3007.000│
  220. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  221. #!│Purpose:      Fills relation and return value fields before Pre and Post  │
  222. #!│              Edit Procedure Calls.                                       │
  223. #!│Called From:  %ScreenEditLookupCode                                       │
  224. #!│              %ScreenSetupRoutines                                        │
  225. #!│Assumptions:  That a %Relation exists between the screen field file and   │
  226. #!│              the return value, or Must-Be-in-File is set for the screen  │
  227. #!│              entry field.  In either case, %Relation is assumed to be    │
  228. #!│              #FIXed.                                                     │
  229. #!│              That %LocateField is set to EITHER Edit or Setup Return     │
  230. #!│              value                                                       │
  231. #!│Inserts:      None                                                        │
  232. #!│Symbols Set:  None                                                        │
  233. #!│Notes:        None                                                        │
  234. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  235. #!│Version   Comments                                                        │
  236. #!│────────  ────────────────────────────────────────────────────────────────│
  237. #!│3007.000  Release of CDD3 version 3007 templates                          │
  238. #!└──────────────────────────────────────────────────────────────────────────┘
  239. #!
  240. #SET(%AssignReturnValue,%LocateField)            #! Default Return Value Assign
  241. #FOR(%RelationKeyField)                          #! FOR fields in Relation Key
  242. %RelationKeyField = %RelationKeyFieldLink        #<! Prime Related Field
  243.   #IF(UPPER(%RelationKeyFieldLink) = UPPER(%ScreenFieldUse)) #! IF Link was written
  244.     #IF(UPPER(%RelationKeyField) = UPPER(%LocateField)) #! IF Linked to Return Value
  245.       #SET(%AssignReturnValue,%Null)             #! Clear Return Value Flag
  246.     #ENDIF                                       #! END (IF Linked to...)
  247.     #BREAK                                       #! Quit Processing
  248.   #ENDIF                                         #! END (If Link written)
  249. #ENDFOR                                          #! END (For RelationKeyField)
  250. #IF(%AssignReturnValue)                          #! IF Assignment needed
  251. %LocateField = %ScreenFieldUse                   #<! Fill the Return Value
  252. #ENDIF                                           #! END (If Assignment Needed)
  253. #!***************************************************************************
  254. #GROUP(%FillRelationFields)                      #!Fill all relation Fields
  255. #!
  256. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  257. #!│                          %PrimeRelationFields          │Version: 3007.000│
  258. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  259. #!│Purpose:      Fills relation and screen field after Pre and Post Edit     │
  260. #!│              Procedure Calls.                                            │
  261. #!│Called From:  %ScreenEditLookupCode                                       │
  262. #!│              %ScreenSetupRoutines                                        │
  263. #!│Assumptions:  That a %Relation exists between the screen field file and   │
  264. #!│              the return value, or Must-Be-in-File is set for the screen  │
  265. #!│              entry field.  In either case, %Relation is assumed to be    │
  266. #!│              #FIXed.                                                     │
  267. #!│              That %LocateField is set to EITHER Edit or Setup Return     │
  268. #!│              value                                                       │
  269. #!│Inserts:      None                                                        │
  270. #!│Symbols Set:  None                                                        │
  271. #!│Notes:        None                                                        │
  272. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  273. #!│Version   Comments                                                        │
  274. #!│────────  ────────────────────────────────────────────────────────────────│
  275. #!│3007.000  Release of CDD3 version 3007 templates                          │
  276. #!└──────────────────────────────────────────────────────────────────────────┘
  277. #!
  278. IF KEYCODE()<>EscKey                             #<! IF User didn't ESCAPE
  279. #SET(%AssignReturnValue,%LocateField)            #! Default Return Value Assign
  280. #FOR(%RelationKeyField)                          #! FOR fields in Relation Key
  281.   %RelationKeyFieldLink = %RelationKeyField      #<! Fill Related Field
  282.   #IF(UPPER(%RelationKeyFieldLink) = UPPER(%ScreenFieldUse)) #! IF Link was written
  283.     #IF(UPPER(%RelationKeyField) = UPPER(%LocateField)) #! IF Linked to Return Value
  284.       #SET(%AssignReturnValue,%Null)             #! Clear Return Value Flag
  285.     #ENDIF                                       #! END (IF Linked to...)
  286.     #BREAK                                       #! Quit Processing
  287.   #ENDIF                                         #! END (If Link written)
  288. #ENDFOR                                          #! END (For RelationKeyField)
  289. #IF(%AssignReturnValue)                          #! IF Assignment needed
  290.   %ScreenFieldUse = %LocateField                 #<! Fill from Return Value
  291. #ENDIF                                           #! END (If Assignment Needed)
  292. END                                              #<! END (If User didn't ESCAPE)
  293. #!***************************************************************************
  294. #GROUP(%ScreenEditLookupCode)                    #!Generate Code for Lookups
  295. #!
  296. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  297. #!│                         %ScreenEditLookupCode          │Version: 3007.000│
  298. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  299. #!│Purpose:      Generates code associated with Must-Be-In-File post-edit    │
  300. #!│              code                                                        │
  301. #!│Called From:  %FieldEditCode                                              │
  302. #!│Assumptions:  None                                                        │
  303. #!│Inserts:      None                                                        │
  304. #!│Symbols Set:  None                                                        │
  305. #!│Notes:        None                                                        │
  306. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  307. #!│Version   Comments                                                        │
  308. #!│────────  ────────────────────────────────────────────────────────────────│
  309. #!│3007.000  Release of CDD3 version 3007 templates                          │
  310. #!└──────────────────────────────────────────────────────────────────────────┘
  311. #!
  312. #IF(%FieldLookup)                                #! IF Must Be In File
  313.                                                  #<! Must be in %FieldLookup
  314. #INSERT(%PrimeRelationFields)                    #! Prime Key Fields
  315. GET(%Relation,%RelationKey)                      #<! Look for parent record
  316.   #IF(%ScreenFieldEditHotKey)                    #! IF a Hot Key is Defined
  317.                                                  #<! %ScreenFieldEditHotKey calls PROC
  318.     #IF(%ScreenFieldRequired)                    #! IF Screen Field is required
  319. IF ERRORCODE() OR KEYCODE() = %ScreenFieldEditHotKey#<! If Not Found or Hotkey
  320.     #ELSE                                        #! ELSE (IF NOT Screen Field...)
  321. IF (%ScreenFieldUse AND ERRORCODE()) OR KEYCODE() = %ScreenFieldEditHotKey#<! If Not Found or Hotkey
  322.     #ENDIF                                       #! END (IF Screen Field...)
  323.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  324.   %ScreenFieldEdit                               #<! Call the Select Proc
  325.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  326.   SELECT(%ScreenField)                           #<! and re-select the field
  327. END                                              #<! END (If No Parent or Hotkey)
  328.   #ELSE                                          #! ELSE (No Hotkey)
  329. IF ERRORCODE()                                   #<! If Not Found
  330.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  331.   %ScreenFieldEdit                               #<! Call the Select Proc
  332.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  333.   SELECT(%ScreenField)                           #<! and re-select the field
  334. END                                              #<! END (If Not Found)
  335.   #ENDIF                                         #! END (If HotKey)
  336. #ELSE                                            #! ELSE (Not Must Be In File)
  337.                                                  #<! Must Be In File NOT SET
  338.   #IF(%ScreenFieldEditHotKey)                    #! IF a Hot Key is Defined
  339.                                                  #<! %ScreenFieldEditHotKey calls PROC
  340. IF KEYCODE() = %ScreenFieldEditHotKey            #<! IF HotKey completed field
  341.   #INSERT(%PrimeRelationFields)                  #! Prime Key Fields
  342.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  343.   %ScreenFieldEdit                               #<! Call the Select Proc
  344.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  345.   SELECT(%ScreenField)                           #<! and re-select the field
  346. END                                              #<! END (If HotKey Pressed)
  347.   #ELSE                                          #! ELSE (No HotKey)
  348.     #IF(%NonStopSelect)                          #! IF In Proc with field validation
  349. IF ~NonStopSelect                                #<! IF NOT in non-stop select
  350.   #INSERT(%PrimeRelationFields)                  #! Prime Key Fields
  351.   SETKEYCODE(ShftEnter)                          #<! Set Keycode for Select
  352.   %ScreenFieldEdit                               #<! Call the Select Proc
  353.   #INSERT(%FillRelationFields)                   #! Fill the key fields
  354. END                                              #<! END (If NOT Non-Stop...)
  355.     #ELSE                                        #! ELSE (Not in Non-Stop Proc)
  356. #INSERT(%PrimeRelationFields)                    #! Prime Key Fields
  357. SETKEYCODE(ShftEnter)                            #<! Set Keycode for Select
  358. %ScreenFieldEdit                                 #<! Call the Select Proc
  359. #INSERT(%FillRelationFields)                     #! Fill the key fields
  360.     #ENDIF                                       #! END (If Non-Stop Select)
  361.   #ENDIF                                         #! END (If Hot Key Defined)
  362. #ENDIF                                           #! END (If Field Lookup)
  363. #!***************************************************************************
  364. #GROUP(%CallScreenFieldEdit)                     #!Call code for non-lookups
  365. #!
  366. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  367. #!│                          %CallScreenFieldEdit          │Version: 3007.000│
  368. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  369. #!│Purpose:      Generates code associated with non-Must-Be-In-File          │
  370. #!│              post-edit code                                              │
  371. #!│Called From:  %FieldEditCode                                              │
  372. #!│Assumptions:  None                                                        │
  373. #!│Inserts:      None                                                        │
  374. #!│Symbols Set:  None                                                        │
  375. #!│Notes:        None                                                        │
  376. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  377. #!│Version   Comments                                                        │
  378. #!│────────  ────────────────────────────────────────────────────────────────│
  379. #!│3007.000  Release of CDD3 version 3007 templates                          │
  380. #!└──────────────────────────────────────────────────────────────────────────┘
  381. #!
  382. #IF(%ScreenFieldEditReturnValue)                 #! IF a Return Value provided
  383. %ScreenFieldEditReturnValue = %ScreenFieldUse    #<! Prime Return Value
  384. #ENDIF                                           #! END (If a Return Value...)
  385. SETKEYCODE(ShftEnter)                            #<! Set KeyCode for Selection
  386. %ScreenFieldEdit                                 #<! Call the Edit Proc
  387. #IF(%ScreenFieldEditReturnValue)                 #! IF a Return Value provided
  388. IF KEYCODE() <> EscKey                           #<! IF User didn't ESCAPE
  389.   %ScreenFieldUse = %ScreenFieldEditReturnValue  #<! Fill the Return Value
  390. END                                              #<! END (If User didn't...)
  391. #ENDIF                                           #! END (If a Return Value...)
  392. #!***************************************************************************
  393. #GROUP(%PrimeLookups)                            #!Prime Lookup Values
  394. #!
  395. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  396. #!│                              %PrimeLookups             │Version: 3007.000│
  397. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  398. #!│Purpose:      Searches the dictionary for lookups or relations for a      │
  399. #!│              screen field                                                │
  400. #!│Called From:  %ScreenSetupRoutines                                        │
  401. #!│              %FieldEditCode                                              │
  402. #!│Assumptions:  None                                                        │
  403. #!│Inserts:      None                                                        │
  404. #!│Symbols Set:  None                                                        │
  405. #!│Notes:        None                                                        │
  406. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  407. #!│Version   Comments                                                        │
  408. #!│────────  ────────────────────────────────────────────────────────────────│
  409. #!│3007.000  Release of CDD3 version 3007 templates                          │
  410. #!└──────────────────────────────────────────────────────────────────────────┘
  411. #!
  412. #IF(%FieldLookup)                                #! IF Must Be In File
  413.   #FIX(%Relation,%FieldLookup)                   #! FIX the Relation to %File
  414.   #IF(%Relation)                                 #! IF the FIX was successful
  415.     #IF(%RelationType='MANY:1')                  #! IF the Relation is Many:1
  416.       #FOR(%RelationKeyField)                    #! Cycle through Key Fields
  417.         #IF(%RelationKeyFieldLink)               #! If a Linked Field Exists
  418.           #IF(UPPER(%RelationKeyFieldLink)=UPPER(%ScreenFieldUse)) #!If Linked Field=Screen Field
  419.             #SET(%LookupFromFile,%Relation)      #! Flag RelatedFile
  420.             #SET(%LookupFromField,%RelationKeyField) #!Flag Related Field
  421.             #BREAK                               #! AND quit Processing
  422.           #ENDIF                                 #! END (IF Linked Field =...)
  423.         #ENDIF                                   #! END (IF Linked Field Exists...)
  424.       #ENDFOR                                    #! END (FOR Key Fields...)
  425.     #ENDIF                                       #! END (If Many:1...)
  426.   #ENDIF                                         #! END (If Valid Relation)
  427. #ELSIF(%LocateField)                             #! ELSE (IF LocateField provided)
  428.   #FOR(%File)                                    #! Search through each file
  429.     #FIX(%Field,%LocateField)                    #! Attempt to fix field
  430.     #IF(%Field)                                  #! IF FIX successful
  431.       #SET(%LookupFromFile,%File)                #! Save Current File
  432.       #FIX(%Field,%ScreenFieldUse)               #! FIX back to screen field
  433.       #FIX(%File,%FieldFile)                     #! FIX back to file
  434.       #FIX(%Relation,%LookupFromFile)            #! FIX relation to saved value
  435.       #SET(%LookupFromFile,%Null)                #! Clear Flag
  436.       #IF(%Relation)                             #! If return value field file
  437.         #IF(%RelationType='MANY:1')              #! IF the Relation is Many:1
  438.           #FOR(%RelationKeyField)                #! Cycle through Key Fields
  439.             #IF(UPPER(%RelationKeyFieldLink)=UPPER(%ScreenFieldUse)) #!If Linked Field=Screen Field
  440.               #IF(UPPER(%RelationKeyField)=UPPER(%LocateField))#! If Linked Field = Locate Field
  441.                 #SET(%LookupFromFile,%Relation)  #! Flag RelatedFile
  442.                 #SET(%LookupFromField,%LocateField) #!Flag Related Field
  443.                 #BREAK                           #! AND quit Processing
  444.               #ENDIF                             #! END (IF Linked Field =...)
  445.             #ENDIF                               #! END (IF Linked Field Exists...)
  446.           #ENDFOR                                #! END (FOR Key Fields...)
  447.         #ENDIF                                   #! END (If Many:1...)
  448.       #ENDIF                                     #! END (If Valid Relation)
  449.       #BREAK                                     #! QUIT Processing Files
  450.     #ENDIF                                       #! END (IF FIX...)
  451.   #ENDFOR                                        #! END (Searching Files)
  452.   #FIX(%Field,%ScreenFieldUse)                   #! FIX back to screen field
  453.   #FIX(%File,%FieldFile)                         #! FIX back to file
  454. #ENDIF                                           #! END (If Must Be...)
  455. #!***************************************************************************
  456. #GROUP(%RangeCode)                               #!Value Range Validation
  457. #!
  458. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  459. #!│                               %RangeCode               │Version: 3007.000│
  460. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  461. #!│Purpose:      Generates Range Validation Code                             │
  462. #!│Called From:  %ScreenEditRoutines                                         │
  463. #!│Assumptions:  None                                                        │
  464. #!│Inserts:      None                                                        │
  465. #!│Symbols Set:  None                                                        │
  466. #!│Notes:        None                                                        │
  467. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  468. #!│Version   Comments                                                        │
  469. #!│────────  ────────────────────────────────────────────────────────────────│
  470. #!│3007.000  Release of CDD3 version 3007 templates                          │
  471. #!└──────────────────────────────────────────────────────────────────────────┘
  472. #!
  473. IF KEYCODE() <> EscKey                           #<! IF user didn't escape
  474. #IF(%FieldRangeLow = %NULL)                      #! If No Low Value provided
  475.   IF %ScreenFieldUse > %FieldRangeHigh           #<! IF field too high
  476.     #INSERT(%FieldValueTooHigh)                  #! Alert the User
  477. #ELSIF(%FieldRangeHigh = %NULL)                  #! ELSE (No High Value provided)
  478.   IF %ScreenFieldUse < %FieldRangeLow            #<! IF field too low
  479.     #INSERT(%FieldValueTooLow)                   #! Alert the User
  480. #ELSE                                            #! ELSE (High and Low provided)
  481.   IF ~INRANGE(%ScreenFieldUse,%FieldRangeLow,%FieldRangeHigh)#<! IF field out of range
  482.     #INSERT(%FieldValueOutOfRange)               #! Alert the User
  483. #ENDIF                                           #! END (If FieldRangeLow...)
  484.     SELECT(%ScreenField)                         #<! Select the same field
  485.     CYCLE                                        #<! and repeat the process
  486.   END                                            #<! END (If bad range value)
  487. END                                              #<! END (If user didn't esc)
  488. #!***************************************************************************
  489. #GROUP(%FieldLookupCode)                         #!Relation Validation Code
  490. #!
  491. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  492. #!│                            %FieldLookupCode            │Version: 3007.000│
  493. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  494. #!│Purpose:      generates Post-Edit Must-Be-In-File field validation        │
  495. #!│Called From:  %ScreenEditRoutines                                         │
  496. #!│Assumptions:  None                                                        │
  497. #!│Inserts:      None                                                        │
  498. #!│Symbols Set:  None                                                        │
  499. #!│Notes:        None                                                        │
  500. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  501. #!│Version   Comments                                                        │
  502. #!│────────  ────────────────────────────────────────────────────────────────│
  503. #!│3007.000  Release of CDD3 version 3007 templates                          │
  504. #!└──────────────────────────────────────────────────────────────────────────┘
  505. #!
  506. #FIX(%Field,%ScreenFieldUse)                     #! FIX to process Field
  507. #FIX(%File,%FieldFile)                           #! FIX to process File
  508. #FIX(%Relation,%FieldLookup)                     #! FIX to process Relation
  509. #IF(%RelationType = 'MANY:1')                    #! IF a MANY:1 Relation
  510. IF KEYCODE() <> EscKey                           #<! IF user didn't escape
  511.   #FOR(%RelationKeyField)                        #! FOR each relation key field
  512.   %RelationKeyField = %RelationKeyFieldLink      #<! Assign linking field value
  513.   #ENDFOR                                        #! END (FOR each relation...)
  514.   GET(%Relation,%RelationKey)                    #<! Lookup record
  515.   IF ERRORCODE()                                 #<! If GET did not succeed ?
  516.   #FIX(%File,%FieldLookup)                       #! FIX to process Relation as File
  517.     CLEAR(%FilePre:Record)                       #<! Clear record if unsuccessful
  518.     #INSERT(%ParentRecordNotFound)               #! Alert the User
  519.     SELECT(%ScreenField)                         #<! Reselect the screen field
  520.   ELSE                                           #<! Else IF Errorcode
  521.     DISPLAY                                      #<! Update screen display
  522.   END                                            #<! End IF Errorcode
  523. END                                              #<! Not EscKey
  524. #ENDIF                                           #! END (IF Many:1)
  525. #!***************************************************************************
  526. #GROUP(%SetGenerationFlags)
  527. #!
  528. #!┌────────────────────────────┤Template Group├────────────┬─────────────────┐
  529. #!│                          %SetGenerationFlags           │Version: 3007.000│
  530. #!├──────────────────────────────┤Description├─────────────┴─────────────────┤
  531. #!│Purpose:      Sets flags to generate CASE SELECTED() and CASE FIELD()     │
  532. #!│              structures in main-body accept loops                        │
  533. #!│Called From:  Any procedure template that has a screen defined            │
  534. #!│Assumptions:  None                                                        │
  535. #!│Inserts:      None                                                        │
  536. #!│Symbols Set:  None                                                        │
  537. #!│Notes:        None                                                        │
  538. #!├───────────────────────────────┤Comments├─────────────────────────────────┤
  539. #!│Version   Comments                                                        │
  540. #!│────────  ────────────────────────────────────────────────────────────────│
  541. #!│3007.000  Release of CDD3 version 3007 templates                          │
  542. #!└──────────────────────────────────────────────────────────────────────────┘
  543. #!
  544. #SET(%SelectedCaseRequired,%Null)                #!
  545. #SET(%FieldCaseRequired,%Null)                   #!
  546. #SET(%HotKeyCaseRequired,%Null)
  547. #IF(%Screen)                                     #!
  548.   #FOR(%ScreenField)                             #!
  549.     #SET(%SearchButton,(UPPER(%ScreenField) & '?'))#!
  550.     #IF(%ScreenFieldSetup)                       #!
  551.       #SET(%SelectedCaseRequired,'TRUE')         #!
  552.     #ELSIF(INSTRING(%SearchButton,%SmartSelectedButtons,1,1))#!
  553.       #SET(%SelectedCaseRequired,'TRUE')         #!
  554.     #ENDIF                                       #!
  555.     #IF(NOT %FieldCaseRequired)                  #!
  556.       #IF(%ScreenFieldEdit)                      #!
  557.         #SET(%FieldCaseRequired,'TRUE')          #!
  558.       #ELSIF(INSTRING(%SearchButton,%SmartFieldButtons,1,1))#!
  559.         #SET(%FieldCaseRequired,'TRUE')          #!
  560.       #ELSIF(%FieldRangeLow)                     #!
  561.         #SET(%FieldCaseRequired,'TRUE')          #!
  562.       #ELSIF(%FieldRangeHigh)                    #!
  563.         #SET(%FieldCaseRequired,'TRUE')          #!
  564.       #ELSIF(%FieldLookup)                       #!
  565.         #SET(%FieldCaseRequired,'TRUE')          #!
  566.       #ENDIF                                     #!
  567.     #ENDIF                                       #!
  568.     #IF(%FieldCaseRequired AND %SelectedCaseRequired)
  569.       #BREAK                                     #!
  570.     #ENDIF                                       #!
  571.   #ENDFOR                                        #!
  572. #ENDIF                                           #!
  573. #IF(NOT %FieldCaseRequired)                      #!
  574.   #IF(%PullDown)                                 #!
  575.     #FOR(%PulldownField)                         #! add all procedure or
  576.       #IF(%PulldownFieldType = 'PROCEDURE')      #! source code calls
  577.         #SET(%FieldCaseRequired,'TRUE')          #!
  578.         #BREAK                                   #!
  579.       #ENDIF                                     #!
  580.     #ENDFOR                                      #!
  581.   #ENDIF                                         #!
  582. #ENDIF                                           #!
  583. #FOR(%HotKey)
  584.   #SET(%HotKeyCaseRequired,'TRUE')
  585.   #BREAK
  586. #ENDFOR
  587. #!***************************************************************************
  588. #CHAIN('BrwsGrps.TPX')
  589.